package com.gxa.mobile.annotation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Objects;

/**
 * @author IKE <hp1041735092@outlook.jp>
 * @date 25/3/2024
 */
public class VerifyCodeValidator implements ConstraintValidator<VerifyCode,String> {
    private static final String VALID_CODE = "^\\d{6}$";
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (Objects.isNull(value) || value.isEmpty()){
            return false;
        }
        return value.matches(VALID_CODE);
    }
}
